<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-teacher-edit" th:object="${teacher}">
            <input id="teacherId" name="teacherId" th:field="*{teacherId}"  type="hidden">
            <input name="deptId"  type="hidden"  th:field="*{deptId}" id="treeId"/>
            <div class="form-group">
                <label class="col-sm-3 control-label">部门名称：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName" th:field="*{deptName}">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">档案编号：</label>
                <div class="col-sm-8">
                    <input id="docNo" name="docNo" th:field="*{docNo}" class="form-control" type="text" readonly  unselectable="on">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">工作岗位：</label>
                <div class="col-sm-8">
                    <input id="jobPost" name="jobPost" th:field="*{jobPost}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">教师名字：</label>
                <div class="col-sm-8">
                    <input id="name" name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">性别：</label>
                <div class="col-sm-8">
                    <select id="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sex}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">电话：</label>
                <div class="col-sm-8">
                    <input id="telephone" name="telephone" th:field="*{telephone}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">民族：</label>
                <div class="col-sm-8">
                    <input id="nation" name="nation" th:field="*{nation}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">出生日期：</label>
                <div class="col-sm-8">
                    <input id="dateBirth" name="dateBirth" th:field="*{dateBirth}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">身高：</label>
                <div class="col-sm-8">
                    <input id="height" name="height" th:field="*{height}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">政治面貌：</label>
                <div class="col-sm-8">
                    <input id="politics" name="politics" th:field="*{politics}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">婚姻：</label>
                <div class="col-sm-8">
                    <select id="marriage" class="form-control m-b" th:with="type=${@dict.getType('zl_xyzlb_huny')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{marriage}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">最高学历：</label>
                <div class="col-sm-8">
                    <input id="education" name="education" th:field="*{education}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">毕业院校：</label>
                <div class="col-sm-8">
                    <input id="graduation" name="graduation" th:field="*{graduation}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">专业：</label>
                <div class="col-sm-8">
                    <input id="major" name="major" th:field="*{major}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">生育状况：</label>
                <div class="col-sm-8">
                    <input id="birth" name="birth" th:field="*{birth}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">办公技能：</label>
                <div class="col-sm-8">
                    <input id="skills" name="skills" th:field="*{skills}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">重大病史：</label>
                <div class="col-sm-8">
                    <select id="illness" class="form-control m-b" th:with="type=${@dict.getType('zl_hyzlb_xiaoh')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{illness}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">亲属是否就职本公司：</label>
                <div class="col-sm-8">
                    <select id="relatives" class="form-control m-b" th:with="type=${@dict.getType('sys_yes_no')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{relatives}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">身份证号：</label>
                <div class="col-sm-8">
                    <input id="idnumber" name="idnumber" th:field="*{idnumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">户籍地址：</label>
                <div class="col-sm-8">
                    <input id="address" name="address" th:field="*{address}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">参加工作年限：</label>
                <div class="col-sm-8">
                    <input id="jobtime" name="jobtime" th:field="*{jobtime}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">现居住地址：</label>
                <div class="col-sm-8">
                    <input id="live" name="live" th:field="*{live}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">邮箱：</label>
                <div class="col-sm-8">
                    <input id="mailbox" name="mailbox" th:field="*{mailbox}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">个人特长：</label>
                <div class="col-sm-8">
                    <input id="speciality" name="speciality" th:field="*{speciality}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">自我描述：</label>
                <div class="col-sm-8">
                    <input id="miaoshu" name="miaoshu" th:field="*{miaoshu}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "project/teacher"
		$("#form-teacher-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});

        function submitHandler() {
            if ($.validate.form()) {
                edit();
            }
        }

        function edit() {

            var deptId = $("input[name='deptId']").val();
            var deptName = $("input[name='deptName']").val();
            var docNo = $("input[name='docNo']").val();
            var jobPost = $("input[name='jobPost']").val();
            var name = $("input[name='name']").val();
            var telephone = $("input[name='telephone']").val();
            var dateBirth = $("input[name='dateBirth']").val();
            var height = $("input[name='height']").val();
            var politics = $("input[name='politics']").val();
            var marriage = $("#marriage option:selected").val();
            var education = $("input[name='education']").val();
            var graduation = $("input[name='graduation']").val();
            var major = $("input[name='major']").val();
            var birth = $("input[name='birth']").val();
            var skills = $("input[name='skills']").val();
            var illness = $("#illness option:selected").val();
            var relatives = $("#relatives option:selected").val();
            var idnumber = $("input[name='idnumber']").val();
            var address = $("input[name='address']").val();
            var jobtime = $("input[name='jobtime']").val();
            var mailbox = $("input[name='mailbox']").val();
            var speciality = $("input[name='speciality']").val();
            var miaoshu = $("input[name='miaoshu']").val();
            var remark = $("input[name='remark']").val();

            var teacherId = $("input[name='teacherId']").val();
            var sex = $("#sex option:selected").val();
            var live = $("input[name='live']").val();

            $.ajax({
                cache : true,
                type : "POST",
                url : ctx + "project/teacher/edit",
                data : {
                    "deptId":deptId,
                    "deptName":deptName,
                    "docNo":docNo,
                    "jobPost":jobPost,
                    "name":name,
                    "telephone":telephone,
                    "dateBirth":dateBirth,
                    "height":height,
                    "politics":politics,
                    "marriage":marriage,
                    "education":education,
                    "graduation":graduation,
                    "major":major,
                    "birth":birth,
                    "skills":skills,
                    "illness":illness,
                    "relatives":relatives,
                    "idnumber":idnumber,
                    "address":address,
                    "jobtime":jobtime,
                    "mailbox":mailbox,
                    "speciality":speciality,
                    "miaoshu":miaoshu,
                    "remark":remark,
                    "teacherId":teacherId,
                    "sex": sex,
                    "live": live

                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.saveSuccess(data);
                }
            });
        }


        /*用户管理-修改-选择部门树*/
        function selectDeptTree() {
            var deptId = $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }
	</script>
</body>
</html>
